fix(billing): use active/trialing status allowlist in requireQuota middleware#3280
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
Updates the billing quota enforcement middleware so only active and trialing subscriptions are treated as paid for quota purposes, aligning quota gating with the billing usage endpoint and ensuring inactive subscription statuses fall back to the free plan.
Changes:
- Replace the
past_due-only check with an['active', 'trialing']allowlist inrequireQuota. - Add unit tests for
canceled,unpaid,incomplete(free fallback) andtrialing(paid plan).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| modules/billing/middlewares/billing.requireQuota.js | Switches plan selection to an active/trialing allowlist so inactive statuses use free quotas. |
| modules/billing/tests/billing.quota.unit.tests.js | Adds targeted unit tests to validate behavior for additional subscription statuses. |
…nactive statuses - Hoist activeStatuses to shared lib/constants.js to avoid duplication between requireQuota middleware and billing controller - Collapse individual inactive-status test cases into test.each table for easier maintenance and extensibility
Summary
past_due-only check inrequireQuotamiddleware with an['active', 'trialing']allowlist, so thatcanceled,unpaid,incomplete, andpausedsubscriptions correctly fall back to the free plancanceled,unpaid,incomplete(treated as free) andtrialing(uses subscription plan)Test plan
billing.quota.unit.tests.js)Closes #3279